﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
using SZORM.Core;
using SZORM.Infrastructure.Interception;

namespace SZORM
{
    public interface IDbContext : IDisposable, IAsyncDisposable
    {
        void BeginTran();
        Task BeginTranAsync();
        void BeginTran(IsolationLevel? il);
        Task BeginTranAsync(IsolationLevel? il);
        void Save();
        Task SaveAsync();
        void Rollback();
        Task RollbackAsync();
        int ExecuteNoQuery(Func<string, string> func, params DbParam[] parameters);
        int ExecuteNoQuery(Func<string, string> func, CommandType cmdType, params DbParam[] parameters);
        Task<int> ExecuteNoQueryAsync(Func<string, string> func, params DbParam[] parameters);
        Task<int> ExecuteNoQueryAsync(Func<string, string> func, CommandType cmdType, params DbParam[] parameters);
        object ExecuteScalar(Func<string, string> func, params DbParam[] parameters);
        object ExecuteScalar(Func<string, string> func, CommandType cmdType, params DbParam[] parameters);
        Task<object> ExecuteScalarAsync(Func<string, string> func, params DbParam[] parameters);
        Task<object> ExecuteScalarAsync(Func<string, string> func, CommandType cmdType, params DbParam[] parameters);
        IDataReader ExecuteReader(Func<string, string> func, params DbParam[] parameters);
        IDataReader ExecuteReader(Func<string, string> func, CommandType cmdType, params DbParam[] parameters);
        Task<IDataReader> ExecuteReaderAsync(Func<string, string> func, params DbParam[] parameters);
        Task<IDataReader> ExecuteReaderAsync(Func<string, string> func, CommandType cmdType, params DbParam[] parameters);
        DataTable ExecuteDataTable(Func<string, string> func, params DbParam[] parameters);
        DataTable ExecuteDataTable(Func<string, string> func, CommandType cmdType, params DbParam[] parameters);
        Task<DataTable> ExecuteDataTableAsync(Func<string, string> func, params DbParam[] parameters);
        Task<DataTable> ExecuteDataTableAsync(Func<string, string> func, CommandType cmdType, params DbParam[] parameters);
        IEnumerable<T> ExecuteSqlToList<T>(Func<string, string> func, params DbParam[] parameters);
        IEnumerable<T> ExecuteSqlToList<T>(Func<string, string> func, CommandType cmdType, params DbParam[] parameters);
    }
}
